#include "../inc/Velocity.hxx"
#include <cmath>

using namespace std;

Velocity::Velocity() {}

Velocity::Velocity(double dX, double dY, double dZ) {
    this->dX = dX;
    this->dY = dY;
    this->dZ = dZ;
    updateSphericalVelocities();
}
/*
Velocity::Velocity(double dAzimuth, double dElevation, double dRadius) {
    this->dAzimuth = dAzimuth;
    this->dElevation = dElevation;
    this->dRadius = dRadius;
    updateCartesianVelocities();
}
*/
double Velocity::getDRadius() {
    return this->dRadius;
}

void Velocity::setDRadius(double dRadius) { 
    this->dRadius = dRadius;
    updateCartesianVelocities();
}

double Velocity::getDAzimuth() {
    return this->dAzimuth;
}

void Velocity::setDElevation(double dElevation) { 
    this->dElevation = dElevation;
    updateCartesianVelocities();
}

double Velocity::getDElevation() {
    return this->dElevation;
}

void Velocity::setDAzimuth(double dAzimuth) { 
    this->dAzimuth = dAzimuth;
    updateCartesianVelocities();
}

double Velocity::getDX() {
    return this->dX;
}

void Velocity::setDX(double dX) { 
    this->dX = dX;
    updateSphericalVelocities();
}

double Velocity::getDY() {
    return this->dY;
}

void Velocity::setDY(double dY) {
    this->dY = dY;
    updateSphericalVelocities();
}

double Velocity::getDZ() {
    return this->dZ;
}

void Velocity::setDZ(double dZ) { 
    this->dZ = dZ;
    updateSphericalVelocities();
}

void Velocity::updateSphericalVelocities() { 
    this->dRadius = sqrt(dX*dX + dY*dY + dZ*dZ);
    this->dElevation = asin(dZ/dRadius);
    this->dAzimuth = atan(dY/dX);    
}

void Velocity::updateCartesianVelocities() { 
    this->dX = dRadius*cos(dAzimuth)*cos(dElevation);
    this->dY = dRadius*sin(dAzimuth)*cos(dElevation);
    this->dZ = dRadius*sin(dElevation);
}

